package org.travel.app.controller;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.travel.app.common.vo.ResultVO;
import org.travel.app.entity.PointsTransactions;
import org.travel.app.entity.user.User;
import org.travel.app.entity.spots.Spots;
import org.travel.app.service.impl.TicketServiceImpl;

/**
 * @author nmm
 * @date 2024-12-2024/12/19
 * @deriction njm......
 */
@RestController
@RequestMapping("/ticket")
@RequiredArgsConstructor
@Slf4j
public class TicketController extends BaseController{
    private  final TicketServiceImpl ticketService;
    @PostMapping("/getTicketBySpotsId")
    public ResultVO getTicketBySpotsId(@RequestBody Spots spots) {
        return success(ticketService.getSpotsTicketById(spots.getSpotId()));
    }

    @PostMapping("/getTicketPackagesBySpotsId")
    public ResultVO getTicketPackagesBySpotsId(@RequestBody Spots spots) {
    	return  success(ticketService.getTicketPackagesBySpotsId(spots.getSpotId()));
    }


    /**
     * 获取前端景点套餐
     * @return
     */
    @GetMapping("/getCustomSpotsPackage")
    public ResultVO getCustomSpotsPackage() {
        return  success(ticketService.getCustomSpotsPackage());
    }


    /**
     * 获取积分商城优惠券
     * @return
     */
    @GetMapping("/getTicketDiscountList")
    public ResultVO getTicketDiscountList() {
    	return success(ticketService.getTicketDiscountList());
    }

    /**
     * 获取当前用户优惠券
     * @param user
     * @return
     */
    @PostMapping("/getUserHasTicketList")
    public ResultVO getUserHasTicketList(@RequestBody User user) {
    	 return  success(ticketService.getUserDetailTicket(user.getUserId()));
    }

    /**
     * 查询前端优惠券
     * @return
     */
    @GetMapping("/getDistinctTicketList")
    public ResultVO getDistinctTicketDiscount() {
        return  success(ticketService.getDistinctTicketDiscount());
    }

    /**
     * 优惠券兑换
     * @param transactions
     * @return
     */
    @PostMapping("/transacationTicket")
    public ResultVO TransacationTicket(@RequestBody PointsTransactions transactions) {
        return success(ticketService.ensureUserHasPoints(transactions));
    }
}